Skip to content

drivers: ethernet: Add Intel® i226 Ethernet Controller Driver #88108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Vijayakannan
Copy link
Contributor

@Vijayakannan Vijayakannan commented Apr 3, 2025

The Intel i226 Ethernet Controller is a PCIe Gen 2 one-lane modular endpoint device that integrates a fully featured GbE Media Access Control (MAC) and Physical Layer (PHY) port. This PR introduces a complete driver bundle to enable Intel i226 Ethernet Controller.

Components:

  • MAC Driver, MDIO Driver & Parent Platform Driver

Features Supported:

  • Full duplex support for 10/100/1000 Mbps.
  • Half duplex support for 10/100 Mbps.
  • MSI-X interrupt support for TX/RX DMA channels.
  • Exclusive bottom-half processing for each hardware queue.
  • Auto-Negotiation for 10/100/1000 Mbps.
  • MTU customization for flexible packet sizes.
  • MAC address filtering support for:
    • Random MAC Address Generated.
    • MAC addresses specified in the device tree.
    • Pre-programmed MAC addresses in EEPROM.
  • MDIO Clause 22 (C22) and Clause 45 (C45) support.
  • Multi-instance support to scale the system. (Tested Up to 2 instances with basic coverage)

Other Notes:

  • The Parent Platform Driver is designed to be modular and reusable for other PCIe-based Ethernet devices.
  • 2.5 Gbps, Time Sync and other TSN features were not enabled despite the hardware having support.

Validation Coverage:
This driver bundle has been tested on Intel Alder Lake platforms with the Intel i226 LM variant Ethernet Controller(0x125B). The ZPERF network sample application was used to validate basic functionality, performance, and stability.

Test List:

  • Transmit and receive UDP packet,
  • Transmit and receive TCP packet,
  • Speed: 10/100/1000Mbps, Duplex: Full, Auto-negotiation: ON, (autoneg initiated from link partner),
  • Speed: 10/100; Duplex: Half, Auto-negotiation: ON, (autoneg initiated from link partner),
  • Speed: 10/100/1000Mbps, Duplex: Full, Auto-negotiation: ON (autoneg initiated from net shell),
  • Speed: 10/100Mbps, Duplex: Half, Auto-negotiation: ON (autoneg initiated from net shell),
  • TX and RX with different MTU sizes: 256, 512, and 1024
  • Throughput KPI for UDP upload and download (100/1000 Mbps),
  • Latency KPI: 100 Mbps, 500 us packet interval with 500,1500 bytes packet size,
  • Latency KPI: 1000 Mbps, 125 us packet interval, 200 bytes packet size,
  • Ethernet Cable hot-plug with different number of hardware queues.
  • MDIO Clause - 22/ 45 Support,
  • Configure MAC address via net shell, device tree and net shell.

Copy link

github-actions bot commented Apr 3, 2025

Hello @Vijayakannan, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

@maass-hamburg
Copy link
Member

On a first look:

  • the Link status change detection should happen in the phy. we have the phy_link_callback_set() to set a callback function in the phy from the mac. In that callback net_eth_carrier_on() and net_eth_carrier_off() should be called.
  • It's generall best to not have code for the phy in the ethernet driver. It's preferd if the official zephyr apis are used for communication between the phy and mac driver.

@Vijayakannan
Copy link
Contributor Author

On a first look:

Hi Fin Maaß, Thanks for spending time to review and recommendations.

  • the Link status change detection should happen in the phy. we have the phy_link_callback_set() to set a callback function in the phy from the mac. In that callback net_eth_carrier_on() and net_eth_carrier_off() should be called.
  • It's generall best to not have code for the phy in the ethernet driver. It's preferd if the official zephyr apis are used for communication between the phy and mac driver.

I agree with your suggestions and work on it.

Rationale on why earlier decided to use MAC for Link detection:
Intel i226 integrates the GbE MAC and PHY into a single chip. Additionally, MAC includes automatic Link detection functionality and update its registers automatically, which simplifies usage. So, in my initial design opted to handle it directly in MAC to avoid the overhead of invoking PHY-to-MAC callback.

I am open for your suggestion in case if you have other thoughts. - Thanks, Vijay

@Vijayakannan Vijayakannan marked this pull request as draft April 23, 2025 05:58
@Vijayakannan
Copy link
Contributor Author

On a first look:

Hi Fin Maaß, Thanks for spending time to review and recommendations.

  • the Link status change detection should happen in the phy. we have the phy_link_callback_set() to set a callback function in the phy from the mac. In that callback net_eth_carrier_on() and net_eth_carrier_off() should be called.
  • It's generall best to not have code for the phy in the ethernet driver. It's preferd if the official zephyr apis are used for communication between the phy and mac driver.

I agree with your suggestions and work on it.

Progress Update:
The interrupt line used for this PHY link status change is shared for multiple purposes as per the hardware design. Therefore, I have started a small refactor to accommodate this review comment and all other use cases. Let me publish the changes once I finish my sanity checks.

@Vijayakannan Vijayakannan force-pushed the dev/vijay/i226_mainline branch 2 times, most recently from 288ebf7 to 03d2fc2 Compare May 13, 2025 20:26
@Vijayakannan Vijayakannan force-pushed the dev/vijay/i226_mainline branch from 0f1a01e to 7210410 Compare July 10, 2025 14:14
@github-actions github-actions bot added the platform: Intel Intel Corporation label Jul 10, 2025
@Vijayakannan
Copy link
Contributor Author

Vijayakannan commented Jul 10, 2025

Hi @maass-hamburg,

All the review comments were addressed in this PR version 7. Please review and share feedback. Thanks, Vijay

Changes since v6:

- Use generic phy driver for i226. (Test Coverage: Got Satisfactory performance results)
	○ Replace the compatible string in device tree to use "ethernet-phy" generic driver.
	○ Remove drivers/ethernet/phy/phy_intel_igc.c
	○ Remove dts/bindings/ethernet/phy/intel,igc-phy.yaml
	○ Clean up drivers/ethernet/phy/CMakeLists.txt.
	○ Clean up drivers/ethernet/phy/Kconfig.

- Remove Miscellaneous interrupts handling codes from the mac driver.
	○ eth_intel_igc_misc_isr
	○ eth_intel_igc_connect_misc_msix_vector
	○ Clean eth_intel_igc_pcie_msix_setup
	○ Clean eth_intel_igc_map_intr_to_vector
	○ eth_intel_igc_intr_enable

- Remove INTEL_IGC_MAC_ASSIGN_ADDR unused macro.
- Move interrupt-parent to parent platform driver.
- Clean up the PR description.
- Fix 3 sonarqubecloud reported issues.

@Vijayakannan Vijayakannan force-pushed the dev/vijay/i226_mainline branch from 7210410 to 3bd0d2e Compare July 11, 2025 06:19
@Vijayakannan
Copy link
Contributor Author

Hi @maass-hamburg, please review and approve this PR.?

@Vijayakannan Vijayakannan force-pushed the dev/vijay/i226_mainline branch from 3bd0d2e to 75fd2a6 Compare July 16, 2025 08:16
@Vijayakannan Vijayakannan force-pushed the dev/vijay/i226_mainline branch from 75fd2a6 to 771b9cc Compare July 16, 2025 15:52
@Vijayakannan
Copy link
Contributor Author

Hi @maass-hamburg, please review PR revision v8.

Changes since PR version v7:
• Cleanup eth_intel_igc_get_phy
• Use sys_read32 and sys_write32.
• Move the intr vector configuration to normal init function.
• Cleanup eth_intel_igc_disable_pcie_master function.
• Remove unused 20millisecond sleep from eth_intel_igc_init_mac_hw.
• Add 1 millisecond delay after MAC reset sequence to settle.
• Relocate eth_intel_igc_map_intr_to_vector and eth_intel_igc_init_speed.
• Refine the inline comments and LOG prints.

@Vijayakannan Vijayakannan force-pushed the dev/vijay/i226_mainline branch from 771b9cc to 5f500c7 Compare July 17, 2025 15:32
@Vijayakannan
Copy link
Contributor Author

Hi @maass-hamburg, please review PR revision v9.

Changes since PR version v8:

  • Remove 0 left and right shift usages in code.
  • Cleanup eth_intel_igc_get_sa_family
  • Remove Long packet receive support. (test the speed with this support)
  • Cleanup INTEL_IGC_SETUP_QUEUE_WORK_EXP macro
  • Cleanup INTEL_IGC_MAC_DATA
  • Use phy-handle to fetch ethernet-phy node in dts.

@Vijayakannan Vijayakannan force-pushed the dev/vijay/i226_mainline branch from 5f500c7 to e3e912d Compare July 18, 2025 11:38
@Vijayakannan
Copy link
Contributor Author

Hi @maass-hamburg, could you please share your feedback on this updated PR version?

Comment on lines 487 to 488
struct eth_intel_igc_mac_tx *tx;
struct eth_intel_igc_mac_rx *rx;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
struct eth_intel_igc_mac_tx *tx;
struct eth_intel_igc_mac_rx *rx;
struct eth_intel_igc_mac_tx tx;
struct eth_intel_igc_mac_rx rx;

I meant this, when I said to put it in it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant this, when I said to put it in it.

Got it. This change requires updating the overall code. I can make the necessary modifications and update this PR.

Please let me know if there are any other review comments to address in the next version. I need to expedite this PR due to the long pending pull request.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant this, when I said to put it in it.

Good catch and suggestion. All the required changes are already resolved in the updated version.

@Vijayakannan Vijayakannan force-pushed the dev/vijay/i226_mainline branch from e3e912d to 45305c5 Compare July 21, 2025 10:47
The Ethernet device model consists of multiple subsystem components, such
as MDIO, PHY, MAC and PTP_CLOCK. These components are mapped into a single
PCIe BAR location with same base address.

This platform driver retrieves the MMIO mapping details and provides a
framework to share it with all the child subsystem components. This
approach avoid the duplicate remapping, ensures efficient re-use of
MMIO mappings across related devices.

Example device tree structure for first ethernet instance:

parent0: parent0 {
        compatible = "intel,eth-plat";
        interrupt-parent = <&intc>;
        vendor-id  = <0x8086>;
        device-id  = <0xXXXX>;

        igc0: igc0 {
                compatible = "intel,igc-mac";

                /*
                 * MAC specific properties.
                 */

                status = "okay";
        };

        mdio0: mdio0 {
                compatible = "intel,igc-mdio";
                #address-cells = <1>;
                #size-cells = <0>;

                ethphy0: ethernet-phy@0 {
                        compatible = "ethernet-phy";
                        /*
                         * PHY specific properties.
                         */
                        reg = <0x0>;
                };
        };
};

This framework is modular and re-usable for other PCIe based Ethernet
devices. It can also be extended to support additional platform specific
information shared across child nodes.

Signed-off-by: Vijayakannan Ayyathurai <vijayakannan.ayyathurai@intel.com>
Intel i226 MAC supports MDIO C22 and MDIO C45. Standard PHY registers
are accessible through MDIO C22, whereas PMAPMD and PCS are accssible
through MDIO C45.

Signed-off-by: Vijayakannan Ayyathurai <vijayakannan.ayyathurai@intel.com>
The Intel i226 Ethernet Controller is a PCIe Gen 2 one-lane modular
endpoint device that integrates a GbE Media Access Control (MAC) and
Physical Layer (PHY) port. This driver provides support for MAC and
DMA-specific initialization and runtime TX/RX operations.

Key features:
- MSI-X interrupts for TX/RX DMA channels.
- Multiple TX/RX DMA channel support with exclusive bottom-half.
- Implements a circular descriptor ring architechture with
  producer-consumer semantics for high performance pkt processing.
- Full duplex support for 10/100/1000 Mbps.
- Half duplex support for 10/100 Mbps.
- Auto-negotiation for 10/100/1000 Mbps.
- MTU customization for flexible packet sizes.
- MAC address filtering based on:
  - Random MAC generation.
  - Local-mac-address mentioned in device tree.
  - EEPROM pre-programmed mac address.
  - Setting mac address via net shell.
- Support for multiple Ethernet interface instances.

Signed-off-by: Vijayakannan Ayyathurai <vijayakannan.ayyathurai@intel.com>
Signed-off-by: Ling Pei Lee <pei.lee.ling@intel.com>
Foxville LM (0x125B) i226 variant and Intel Alder Lake platform was
used for developing and stabilizing the i226 Ethernet device driver.
However, users can reuse the provided device tree models as a reference
when enabling the support for other i226 variants and platforms.

This device-tree model include essential configurations for the i226
Ethernet controller, such as PCIe settings, interrupt mappings, Phy
MDIO, and DMA descriptor configurations.

Signed-off-by: Vijayakannan Ayyathurai <vijayakannan.ayyathurai@intel.com>
The Zperf sample application was chosen to demonstrate basic network
functionality and high-performance use cases. This application serves
as a reference for users who wish to enable other network sample
applications.

In addition to the essential configurations for the Intel i226 Ethernet
controller, stack-specific configurations were added to ensure stability
under heavy network loads. These configurations include adjustments to
buffer sizes, interrupt handling, and DMA descriptor management.

Signed-off-by: Vijayakannan Ayyathurai <vijayakannan.ayyathurai@intel.com>
@Vijayakannan Vijayakannan force-pushed the dev/vijay/i226_mainline branch from 45305c5 to 884a682 Compare July 22, 2025 09:13
Copy link

@Vijayakannan
Copy link
Contributor Author

Hi @jukkar, @tbursztyka, @dcpleung, @pdgendt, @decsny, @nashif

Please add this PR in your review list and share your feedback. Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants